package  
{
	/**
	 * ...
	 * @author Josue
	 */
	import org.flixel.*;
	public class joshue extends FlxSprite
	{
		
		public function joshue(x:Number, y:Number) 
		{
			/* Cuando se crea un nuevo player, lo carga en las coordenadas que tu le dices */
			super(x, y);
			
			/* Carga la imagen */
			this.loadGraphic(Assets.Gallina, true, true, 64, 64);
			
			/* Agrega animaciones del player */
			this.addAnimation("Normal", [8], 5);
			this.addAnimation("Correr", [0, 1, 2, 3, 4, 5, 6, 7], 5);
			this.addAnimation("Salto", [16, 17, 18, 19, 20, 21, 22, 23], 5);
			
			/* Cuando se crea el personaje siempre aparecera en la animacion indicada */
			this.play("Normal");
		}
		
		override public function update():void
		{
			/* Movimiento del player */
			if (FlxG.keys.D && this.x < FlxG.stage.width - width)
			{
				
				this.facing = RIGHT;
				this.velocity.x = 100;
				this.play("Correr");
			}
			else if (FlxG.keys.A && this.x > 0)
			{
				this.facing = LEFT;
				this.velocity.x = -100;
				this.play("Correr");
			}
			else if (FlxG.keys.W && this.y > 0)
			{
				this.facing = UP;
				this.velocity.y = -100;
				this.play("Salto");
			}
			else if (FlxG.keys.S && this.y < FlxG.stage.height - height - 100) //El -100 es provicional
			{
				this.facing = DOWN;
				this.velocity.y = 100;
				this.play("Salto");
			}
			else
			{
				this.velocity.x = 0;
				this.velocity.y = 0;
				this.play("Normal");
			}
		}
		
	}

}